package com.astro.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.astro.domain.bean.UserAccount;

@Repository("userAccountDAO")
public class UserAccountDAO extends BaseHelperDAO {

	@SuppressWarnings("unchecked")
	public List<UserAccount> listUserAccount(Long userId) throws Exception {
		List<UserAccount> result = null;
		
		String queryString = "from UserAccount where userId = :userId"; // Hibernate Query Language
		result = getCurrentSession().createQuery(queryString).setParameter("userId", userId).list();
		
		return result;
	}
	
	/**
	 * Insert customer into database
	 */
	public void addUser(UserAccount entity) throws Exception {
		// Insert into database
		getCurrentSession().save(entity);
	}
}